home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1995 #2 / Amiga Plus CD - 1995 - No. 2.iso / internet / faq / englisch / computer-security-compromise < prev    next >
Encoding:
Text File  |  1995-04-11  |  14.3 KB  |  312 lines

  1. Archive-name: computer-security/compromise-faq 
  2. Posting-frequency: monthly
  3. Last-modified: 1995/01/02
  4. Version: 2.0
  5.  
  6. Compromise FAQ
  7.  
  8. Version: 2.0
  9.     ------------------------------------------------------------------------
  10.  
  11. This Security FAQ is a resource provided by:
  12.  
  13.      Internet Security Systems, Inc.
  14.      2000 Miller Court West            Tel: (404) 441-2531
  15.      Norcross, Georgia  30071          Fax: (404) 441-2431
  16.  
  17.      - Computer Security Consulting - Penetration Analysis of Networks -
  18.  
  19.     ------------------------------------------------------------------------
  20.  
  21. To get the newest updates of Security files check the following services:
  22.  
  23.      mail info@iss.net with "send index" in message
  24.      http://iss.net/~iss
  25.      ftp iss.net /pub/
  26.  
  27.     ------------------------------------------------------------------------
  28.  
  29.  
  30. What if your Machines are Compromised by an Intruder.
  31.  
  32. This FAQ deals with some suggestions for securing your Unix machine after it
  33. has already been compromised. Even if your machines have not been compromised,
  34. there are many helpful tips on securing a machine in this paper.
  35.  
  36.   1.  Try to trace/follow the intruder back to his origin via looking at
  37.  
  38.        1.  who
  39.        2.  w
  40.        3.  last
  41.        4.  lastcomm
  42.        5.  netstat
  43.        6.  snmpnetstat
  44.        7.  router information.
  45.        8.  /var/adm/messages (many crackers send e-mail to their "home"
  46.           accounts)
  47.        9.  syslog (sends logs to other hosts as well)
  48.       10.  wrapper logs
  49.       11.  do a 'finger' to all local users(and check where they last logged in
  50.           from)
  51.       12.  history files from shells, such as .history, .rchist, and similiar
  52.           files.
  53.  
  54.      Footnote: 'who', 'w', 'last', and 'lastcomm' are commands that rely on
  55.      /var/adm/pacct, /usr/adm/wtmp, and /etc/utmp to report the information to
  56.      you. Most backdoors will keep the intruder from being shown in these logs.
  57.      Even if the intruder has not installed any backdoors yet, it is trivial to
  58.      remove any detection in these logs. But they may just forget about one or
  59.      two of them. Especially if you have some additional, non-standard ones.
  60.  
  61.      Suggestion: Install xinetd or tcp_wrapper that will log all connections to
  62.      your machine to see if someone is knocking on its doors. Forward syslogs
  63.      to another machine so intruder will not easily detect the logs and modify.
  64.      Other possibilities: netlog from net.tamu.edu:/pub/security.
  65.  
  66.      It might be wise to monitor the intruder via some ethernet sniffer to see
  67.      how he is exploiting his systems before taking corrective measures.
  68.  
  69.   2.  Close the machine from outside access. Remove from network to stop
  70.      further access via intruder. If the intruder finds out that the
  71.      administrator is unto him, he may try to hide his tracks by rm -rf /.
  72.  
  73.   3.  Check the binaries with the originals. Especially check the following
  74.      binaries because they are commonly replaced backdoors for regaining
  75.      access:
  76.  
  77.        1.  /bin/login
  78.        2.  all the /usr/etc/in.* files (ie. in.telnetd)
  79.        3.  and /lib/libc.so.* (on Suns).
  80.        4.  anything called from inetd
  81.  
  82.      Other commonly replaced backdoor binaries:
  83.  
  84.        1.  netstat - allows hiding connections
  85.        2.  ps - allows hiding processes (ie Crack)
  86.        3.  ls - allows hiding directories
  87.        4.  ifconfig - hides the fact that promiscuity mode is on the ethernet
  88.        5.  sum - fools the checksum for binaries, not necessarily replaced
  89.           anymore because its possible to change the checksum of the binaries
  90.           to the correct value without modifying sum. *EMPHASIZE* Do NOT Rely
  91.           on sum.
  92.  
  93.      Use 'ls -lac' to find the real modification time of files. Check /etc/wtmp
  94.      (if you still have one) for any system time adjustments. Check the files
  95.      with the distribution media (CD or tape) or calculate MD5 checksums and
  96.      compare them with the originals kept offline (you did calculate them
  97.      sometime ago, didn't you?) Suggestion: cmp the files with copies that are
  98.      known to be good.
  99.  
  100.      Another popular backdoor is suid'ing a common command (ie. /bin/time) to
  101.      allow root access with regular accounts.
  102.  
  103.      To find all suid programs you may use:
  104.  
  105.           find / -type f -perm -4000 -ls
  106.  
  107.      To be thorough you may need to re-load the entire OS to make sure there
  108.      are no backdoors. Tripwire helps prevent modifying binaries and system
  109.      files (ie. inetd.conf) on the system, without the administrator knowing.
  110.  
  111.   4.  Implement some password scheme for your users to verify that they change
  112.      their passwords often. Install anlpasswd, npasswd, or passwd+ in place of
  113.      passwd (or yppasswd) so that your users are forced to set reasonable
  114.      passwords. Then run Crack, which is available on
  115.      ftp.cert.org:/pub/tools/crack to make sure that your users aren't
  116.      bypassing the password check. Crack ensures that users are picking
  117.      difficult passwords. With the network, clear text passwords are a problem.
  118.      Other possible choices: smart hubs (stops ethernet sniffing of the whole
  119.      LAN) and one-time password technology.
  120.  
  121.   5.  Check all the users' .rhosts and .forward files to make sure none of them
  122.      are weird or out of the ordinary. If .rhosts file contains '+ +', the
  123.      account can be accessed anywhere by anyone without a password. COPS has a
  124.      scripts for checking .rhosts.
  125.  
  126.           find / -name .rhosts -ls -o -name .forward -ls
  127.  
  128.      Look also for all the files created/modified in the time you are
  129.      suspecting the break-in has taken place, eg:
  130.  
  131.           find / -ctime -2 -ctime +1 -ls
  132.  
  133.      To find all the files modified not less than one day ago, but not more
  134.      than 2.
  135.  
  136.      All .login, .logout, .profile, .cshrc files are also worth looking at (at
  137.      least for the modification date/time). Make sure there are no '.rhosts'
  138.      for the locked or special accounts (like 'news', 'sundiag', 'sync', etc.)
  139.      The shell for such accounts should be something like '/bin/false' anyway
  140.      (and not '/bin/sh') to make them more secure. Also search for directories
  141.      that have like ". ", ".. " as names. They are usually found in /tmp ,
  142.      /var/tmp, /usr/spool/* and any other publicly writeable directory.
  143.  
  144.   6.  Check to make sure your NFS exports are not world writable to everyone.
  145.      NFSwatch available on harbor.ecn.purdue.edu:/pub/davy , a program by David
  146.      Curry, will log any NFS transactions that are taking place. Try 'showmount
  147.      -e' to see whether system agrees with your opinion of what are you
  148.      exporting and where. There are bugs in some nfsd implementations which
  149.      ignore the access lists when they exceed some limit (256 bytes). Check
  150.      also what are you IMPORTING!!! Use 'nosuid' flag whenever possible. You do
  151.      not want to be cracked by a sysadm from another host (or a cracker there)
  152.      running suid programs mounted via NFS, do you?
  153.  
  154.   7.  Make sure you have implemented the newest sendmail daemon. Old sendmail
  155.      daemons allowed remote execution of commands on any Unix machine. See the
  156.      computer-security/security-patch FAQ.
  157.  
  158.   8.  Try to install all the security patches available from the vendor on your
  159.      machine. See the computer-security/security-patch FAQ.
  160.  
  161.   9.  Here is a check list of common ways that a machine is vulnerable:
  162.  
  163.        1.  Do an rpcinfo -p on your machine to make sure it is not running any
  164.           processes that are not needed. (ie. rexd).
  165.  
  166.        2.  Check for '+' in /etc/hosts.equiv.
  167.  
  168.        3.  Check whether tftp is disabled on your system. If not - disable it,
  169.           or at least use '-s' flag to chroot it to some safe area, if you
  170.           really can't live without it (it is mostly used for booting up
  171.           Xterminals, but sometimes can be avoided by NFS-mounting appropriate
  172.           disks). Under no circumstances you should run it as root. Change the
  173.           line describing it in /etc/inetd.conf to something like:
  174.  
  175.                tftp dgram udp wait nobody /usr/etc/in.tftpd in.tftpd -s
  176.                /tftpboot
  177.  
  178.           or better yet, use tcpd wrapper program to protect it from addresses
  179.           which should not get access to tftp and log all other connections:
  180.  
  181.                tftp dgram udp wait nobody /usr/etc/tcpd in.tftpd -s
  182.                /tftpboot
  183.  
  184.           and edit appropriately /etc/hosts.allow to restrict access to
  185.           in.tftpd to only those addresses that really need it.
  186.  
  187.        4.  Check crontabs and at-jobs. Make sure there are no delayed bombs
  188.           which will explode after you think you have got rid of all the nasty
  189.           things left by a intruder.
  190.  
  191.        5.  Check /etc/rc.boot /etc/rc.local (SYSV: /etc/rc?.d/* ) and other
  192.           files cruicial for the system startup. (The best would be if you
  193.           could compare them with the copies kept off-line). Check all other
  194.           files containing system configuration (sendmail.cf, sendmail.fc,
  195.           hosts.allow, at.allow, at.deny, cron.allow, hosts, hosts.lpd, etc.)
  196.           In 'aliases' look for aliases expanding to some unusual programs
  197.           (uudecode is one but example).
  198.  
  199.        6.  Check your inetd.conf and /etc/services files to find if there are
  200.           no additional services set up by an intruder.
  201.  
  202.        7.  Copy all the log files you still have (pacct, wtmp, lastlog, sulog,
  203.           syslog, authlog, any additional logs you have set up earlier) to some
  204.           safe place (offline) so you may examine them later. Otherwise, do not
  205.           be surprised if they disappear the next day when the cracker realises
  206.           he forgot to remove one of them. Use your own imagination to find
  207.           what other traces he could have left in your system (What about
  208.           /tmp/* files? Check them BEFORE you reboot).
  209.  
  210.        8.  Make backup copy of /etc/passwd (best offline) then change all root
  211.           passwords (after verifying that 'su' and 'passwd' are not the trojan
  212.           versions left by an intruder). It may sound like a horrible thing to
  213.           do (especially if you have something like 2000 users) but *do* lock
  214.           them all by putting '*' in the password field. If the intruder has a
  215.           copy of your passwords file he may possibly sooner or later guess all
  216.           the passwords contained there (It is all the matter of proper
  217.           dictionaries). In fact he could have inserted few passwords that he
  218.           only knows for some users who for example have not logged in for a
  219.           long time.
  220.  
  221.           On the NIS servers check not only the real /etc/passwd /etc/groups
  222.           etc files but also those used for building NIS maps (if they are
  223.           different).
  224.  
  225.        9.  Check if your anonymous ftp (and other services) are configured
  226.           properly (if you have any of course) See the
  227.           computer-security/anonymous-ftp FAQ.
  228.  
  229.       10.  If you want to make your life easier next time (or if you still
  230.           cannot get rid of an intruder) consider installing 'ident' daemon.
  231.           Together with tcpd on a set of hosts it can be used to find what
  232.           accounts the intruder is using.
  233.  
  234.       11.  Make sure the only 'secure' terminal is console (if at all). This
  235.           way you prevent root logins just from the net. Maybe it is not a big
  236.           deal as if somebody knows the root password he may already know other
  237.           peoples' passwords too, but maybe not?
  238.  
  239.       12.  Check hosts.equiv, .rhosts, and hosts.lpd for having # as comments
  240.           within those files. If an intruder changes his hostname to #, it will
  241.           be considered a trusted host and allow him to access your machines.
  242.  
  243.       13.  And remember... There are so many ways that somebody could have
  244.           modified your system, that you really have to have your eyes and ears
  245.           wide open for a loooooong long time. Above, are the pointers just to
  246.           the most obvious things to check.
  247.  
  248.  10.  Mail all the sites that you were able to find out that the intruder was
  249.      going through and warn them. Also, CC: cert@cert.org. Check all the sites
  250.      in your near-by, ie. in your domain/institution/whatever. It's usually
  251.      trivial for a hacker to get to another system by a simple 'rlogin' if the
  252.      two systems have a common subset of users (and using .rhosts to make the
  253.      access easier).
  254.  
  255.  11.  A preventive from stopping many intruders from even trying your network
  256.      is to install a firewall.
  257.  
  258.      Side-effects: Firewalls may be expensive; filtering may slow down the
  259.      network. Consider blocking nfs (port 2049/udp) and portmap(111/udp) on
  260.      your router. The authentication and access controls of these protocols is
  261.      often minimal. Suggestion: Block all udp ports except DNS and NTP ports.
  262.      Kill all source routing packets. Kill all ip-forwarding packets.
  263.  
  264. Acknowledgements
  265.  
  266. Thanks to the following people for adding and shaping this FAQ:
  267.  
  268. Tomasz Surmacz <tsurmacz@asic.ict.pwr.wroc.pl>
  269. Wes Morgan (morgan@engr.uky.edu)
  270. Alan Hannan (alan@noc1.mid.net)
  271. Peter Van Epp <vanepp@sfu.ca>
  272. Richard Jones <electron@suburbia.apana.org.au>
  273. Wieste Venema <wietse@wzv.win.tue.nl>
  274. Adrian Rodriguez <adrian@caip.rutgers.edu>
  275. Jill Bowyer <jbowyer@selma.hq.af.mil>
  276. Andy Mell <amell@cup.cam.ac.uk>
  277.  
  278.     ------------------------------------------------------------------------
  279.  
  280.  
  281. Copyright
  282.  
  283. This paper is Copyright (c) 1994, 1995
  284.    by Christopher Klaus of Internet Security Systems, Inc.
  285.  
  286. Permission is hereby granted to give away free copies electronically. You may
  287. distribute, transfer, or spread this paper electronically. You may not pretend
  288. that you wrote it. This copyright notice must be maintained in any copy made.
  289. If you wish to reprint the whole or any part of this paper in any other medium
  290. excluding electronic medium, please ask the author for permission.
  291.  
  292. Disclaimer
  293.  
  294. The information within this paper may change without notice. Use of this
  295. information constitutes acceptance for use in an AS IS condition. There are NO
  296. warranties with regard to this information. In no event shall the author be
  297. liable for any damages whatsoever arising out of or in connection with the use
  298. or spread of this information. Any use of this information is at the user's own
  299. risk.
  300.  
  301. Address of Author
  302.  
  303. Please send suggestions, updates, and comments to:
  304. Christopher Klaus <cklaus@iss.net> of Internet Security Systems, Inc.
  305. <iss@iss.net>
  306.  
  307.  
  308. -- 
  309. Christopher William Klaus       Voice: (404)441-2531. Fax: (404)441-2431
  310. Internet Security Systems, Inc.         Computer Security Consulting
  311. 2000 Miller Court West, Norcross, GA 30071
  312.